<?php
namespace app\pub\util;

use think\Response as ResponseThink;
use think\Lang;

class Upload
{
    public function __construct(){}
    public static function get_upload_img($key = [],$is_array = false){
        $result = [];
        $file_path = ROOT_PATH . 'public' . DS . 'uploads';
        $url = DS . 'uploads'.DS.date('Ymd').DS;
        foreach ($key as $value){
            if($is_array){
                $file = request()->file($value);
            }else{
                $file = request()->file($value.'/a');
            }
            if(is_array($file) && count($file) > 0){
                foreach ($file as $fileValue){
                    if($fileValue){
                        $info = $fileValue->move($file_path);
                        if($info){
                            $path = $url.$info->getFilename();
                            $result[$value][] = $path;
                        }else{
                            return false;
                        }
                    }
                }
            }
        }
        return $result;
    }
}
